﻿@model Fap.AspNetCore.ViewModel.JqGridViewModel
<fap-grid id="paycaseEmployee" grid-model="Model" source-type="Local" shrink-fit="false" wrapper="modal-body" auto-width="true"></fap-grid>
<script>
    function loadPaycaseEmployee(caseUid) {
        $.get(basePath + "/Payroll/Api/PaySet/" + caseUid,function (rv) {
            if (rv.success) {
                if (rv.data.empCondition ===null||rv.data.empCondition==="") {
                    $('#grid-paycaseEmployee').jqGrid('setGridParam', { datatype: 'json' });
                    return;
                }
                $("#fbox_grid-paycaseEmployee").jqFilter("addFilter", JSON.parse(rv.data.empCondition));
                reloadGrid("grid-paycaseEmployee", { filters: rv.data.empCondition });
            }
        })
    }
    function savePaycaseCondition(caseUid) {
        var jqPostData = $('#grid-paycaseEmployee').jqGrid("getGridParam", "postData");
        var filters = jqPostData.filters;
        if (filters === undefined) {
            bootbox.alert($("please_set_paycase_employee_condition", "请设置薪资套员工条件"));
            return;
        }
        $.post(basePath + "/Payroll/Api/PayCondition", { caseUid: caseUid, filters: filters }, function (rv) {
            if (rv.success) {
                $.msg(rv.msg);
            } else {
                bootbox.alert(rv.msg);
            }
        })
    }
    function initPaycaseEmployee(caseUid) {
        var index= layer.load();
        $.post(basePath + "/Payroll/Api/InitPaycaseEmployee", { caseUid, caseUid }, function (rv) {
            if (rv.success) {
                $.msg(rv.msg);
            } else {
                bootbox.alert(rv.msg);
            }
            layer.close(index);
        })
    }
</script>